package com.khalil.kkadmin.common.util;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.UUID;

public class IdTool {

    public static String uuid() {
        return uuid(UUIdConfig.builder().withLine(false).isLower(true).isUpper(false).build());
    }

    public static String uuid(UUIdConfig config) {
        String uuid = UUID.randomUUID().toString();
        if (config.withLine) {
            uuid = uuid.replaceAll("-", "");
        }
        if (config.isLower) {
            uuid = uuid.toLowerCase();
        } else if (config.isUpper) {
            uuid = uuid.toUpperCase();
        }
        return uuid;
    }


    @AllArgsConstructor
    @Data
    @Builder
    static class UUIdConfig {
        private boolean withLine = false;
        private boolean isLower = true;
        private boolean isUpper = false;
    }
}
